FPtrNuller< T > Struct Template Reference

Template definition for classes that help guarding against dangling pointers. More...

#include <fcleanup.h>

Public Member Functions

 FPtrNuller (T *&_toNull)
 Constructor. _toNull is a reference to the pointer that is to be reset to NULL when this FPtrNuller object's destructor is executed.
 ~FPtrNuller ()
 Destructor. Calls delete[] on the at construction time passed pointer.

Data Fields

T *& toNull
 Remembers the pointer that is to be set to NULL during destruction.

Detailed Description

template<class T>
struct Steinberg::FPtrNuller< T >

Template definition for classes that help guarding against dangling pointers.

A stack allocated object of this type autonomically resets an at construction time passed pointer to null when it reaches the end of its scope.

Intended usage:

   int* pointerToInt = 0;
   {
      int i = 1;
      pointerToInt = &i;
      Steinberg::FPtrNuller<int> ptrNuller (pointerToInt);

      // Do something with pointerToInt.

   } // No dangling pointer here, pointerToInt is reset to 0 by destructor of ptrNuller.

Constructor & Destructor Documentation

FPtrNuller ( T *&  _toNull  )  [inline]

Constructor. _toNull is a reference to the pointer that is to be reset to NULL when this FPtrNuller object's destructor is executed.

~FPtrNuller (  )  [inline]

Destructor. Calls delete[] on the at construction time passed pointer.


Field Documentation

T*& toNull

Remembers the pointer that is to be set to NULL during destruction.

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Empty

Copyright ©2013 Steinberg Media Technologies GmbH. All Rights Reserved.